package com.fuershiye.woman.monitor.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fuershiye.woman.monitor.beans.IdName;
import com.fuershiye.woman.monitor.beans.IdNamePid;
import com.fuershiye.woman.monitor.beans.Page;
import com.fuershiye.woman.monitor.dao.AreaDao;
import com.fuershiye.woman.monitor.model.Area;
import com.fuershiye.woman.monitor.service.AreaService;

@Service("areaService")
public class AreaServiceImpl implements AreaService {

	@Autowired
	private AreaDao itDao;
	@Override
	public void save(Area it) {
		itDao.save(it);
	}

	@Override
	public Area get(Long id) {
		return itDao.get(id);
	}
	/**
	 * 取当前表中最大数据
	 * 
	 * @return
	 */
	@Override
	public Area getTop() {
		return itDao.getTop();
	}
	/**
	 *            sort(当前位置)
	 * @param aim
	 *            方向 (1:比id大的; 2:比id小的)
	 * @param count
	 *            取几条数据StringLockPrefix.java
	 * @return
	 */
	@Override
	public Area findBySort(Long sort, Integer aim, Integer count) {
		return itDao.findBySort(sort,aim,count);
	}
	@Override
	public Area findByCode(String code) {
		return itDao.findByCode(code);
	}

	@Override
	public List<Area> list(String name, Long pid, Integer level,Integer status, Page page) {
		return itDao.list(name, pid, level, status, page);
	}
	
    @Override
    public int getTotal(String name, Long pid, Integer level, Integer status) {
    	return itDao.getTotal(name, pid, level, status);
    }

	@Override
	public List<IdNamePid> getAllNames() {
		return itDao.getByLevelAndPid(null, null);
	}
	
	@Override
	public List<IdNamePid> getByLevelAndPid (Integer level, Long pid) {
		return itDao.getByLevelAndPid (level, pid);
	}

	@Override
	public List<IdName> getIdNameByLevelAndPid (Integer level, Long pid) {
		return itDao.getIdNameByLevelAndPid (level, pid, null);
	}
	@Override
	public List<IdName> listByLevel(Integer level, Integer status) {
		return itDao.getIdNameByLevelAndPid (level, null, status);
	}

}
